<?php

namespace app\api\controller\curriculum;

use app\api\controller\Controllers;
use app\api\service\curriculum\Curriculum as CurriculumService;
use app\api\model\curriculum\Curriculum as CurriculumModels;
use app\api\service\order\Order;

class Curriculum extends Controllers
{

    /**
     * 根据课程类型获取列表
     *
     * @return \think\Response
     */
    public function lists(int $category, CurriculumService $service)
    {
        return success($service->category($category));
    }

    /**
     * 获取课程详情
     * @param CurriculumModels $model
     *
     * @return \think\Response
     */
    public function detail(CurriculumModels $model)
    {
        return success([
            'data'=>$model->append(['type_text','detail_html']),
            'school_timetable'=>$model->schoolTimetable,
            'teacher' => $model->teacher
        ]);
    }

    /**
     * 订单详情
     * @param CurriculumModels $model
     *
     * @return \think\Response
     */
    public function order( CurriculumModels $model )
    {
        return success($model->append(['type_text']));
    }

    /**
     * 我的课程
     *
     * @return \think\Response
     */
    public function mine( Order $order )
    {
        return success($order->mineCurriculum());
    }

}
